# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/11 22:10
# @Author   : Robot-Zsj
"""
description:

input
XXYYXY
output
2
"""

s = input()


def getResult():
    countX = 0
    countY = 0

    ans = 0

    for c in s:
        if c == 'X':
            countX += 1
        else:
            countY += 1

        if countX == countY:
            ans += 1
    return ans


print(getResult())
